package com.buddies.lottery.ui.user.pwd;

import com.buddies.lottery.base.BasePresenter;
import com.buddies.lottery.data.BaseObserver;
import com.buddies.lottery.data.DataManager;
import com.buddies.lottery.data.resp.LoginResponse;

/**
 * Created by xuliang on 2018/2/28.
 */

public class ResetPasswordPresenter extends BasePresenter<ResetPasswordContract.View> implements ResetPasswordContract.Presenter {

    public ResetPasswordPresenter(ResetPasswordContract.View view) {
        super(view);
    }

    @Override
    public void postResetPwd(String oldPassword, String newPassword) {
        addSubscription(DataManager.getInstance().getUserRepo().postResetPassword(oldPassword, newPassword), new BaseObserver<LoginResponse>() {
            @Override
            public void onNext(LoginResponse response) {
                mView.onResetPwdSuccess(response.user);
            }

            @Override
            public void onError(Throwable e) {
               mView.onError(e);
            }
        });
    }

}
